package com.wml.sellPhone.service.impl;

import com.wml.sellPhone.dao.MobileMapper;
import com.wml.sellPhone.pojo.Mobile;
import com.wml.sellPhone.service.IMobileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 手机服务实现类
 *
 * @author Hayes
 * @date 2018-06-27 15:33
 */
@Service
public class MobileServiceImpl implements IMobileService {

    @Autowired
    private MobileMapper mobileMapper;

    /**
     * 通过ID查询手机
     * @param id 主键ID
     * @return
     */
    @Override
    public Mobile selectItemById(Long id) {
        Mobile mobile = mobileMapper.selectByPrimaryKey(id);
        return mobile;
    }

    /**
     * 通过品牌查询手机
     * @param brand
     * @return
     */
    @Override
    public List<Mobile> selectPhoneItemsByBrand(String brand) {
        List<Mobile> mobileList = mobileMapper.selectByBrand(brand);
        return mobileList;
    }

    /**
     * 通过手机名模糊查询
     * @param phoneName
     * @return
     */
    @Override
    public List<Mobile> selectPhoneItemsByPhoneName(String phoneName) {
        List<Mobile> mobileList = mobileMapper.selectByPhoneName(phoneName);
        return mobileList;
    }

    /**
     * 根据搜索关键字查询手机条目
     * @param content 搜索关键字
     * @return
     */
    @Override
    public List<Mobile> selectPhoneItems(String content) {
        List<Mobile> mobileList = mobileMapper.selectPhoneItems(content);
        return mobileList;
    }


}
